package com.mingqijia.gassafety.job.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.mingqijia.gassafety.db.entity.DeviceState;
import com.mingqijia.gassafety.db.entity.Dtu;
import com.mingqijia.gassafety.db.entity.vo.DeviceStateVO;
import com.mingqijia.gassafety.db.entity.vo.LatestLogListVO;
import com.mingqijia.gassafety.db.mapper.DeviceStateMapper;
import com.mingqijia.gassafety.job.service.DeviceStateService;
import com.mingqijia.gassafety.shared.utils.commonUtils.PageUtil;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 报警器设备状态更新表 服务实现类
 * </p>
 *
 * @author guoliang.lao
 * @since 2022-08-03
 */
@Service
public class DeviceStateServiceImpl extends ServiceImpl<DeviceStateMapper, DeviceState> implements DeviceStateService {

    @Override
    public PageUtil<DeviceStateVO> getDeviceStateList(LatestLogListVO params) {
        Page<Dtu> page = PageHelper.startPage(params.getPage(), params.getPageSize());
        List<DeviceStateVO> list = baseMapper.getDeviceStateList(params);
        PageUtil pageInfo = new PageUtil<>(params.getPage(), params.getPageSize(), page.getTotal(), list);
        return pageInfo;
    }

    @Override
    public DeviceStateVO getDeviceStateByImei(String imei,String spId) {
        return baseMapper.getDeviceStateByImei(imei,spId);
    }

    @Override
    public List<Map<String,Object>> getDeviceStateSummary(String spId) {
        return baseMapper.getDeviceStateSummary(spId);
    }
}
